﻿package clips
{	
	import events.MoveEvent;
	import fl.ik.*;
	import physic.Engine;

	public class Poignee extends Draggable
	{
		public var _ikMover:IKMover;
		public var _ikJoint:IKJoint;
		
		public function Poignee( ikMover:IKMover=null, ikJoint:IKJoint=null )
		{
			_ikJoint = ikJoint;
			_ikMover = ikMover;
			
			//_ikMover.limitIteration ?????
			
			addEventListener( MoveEvent.MOVING, moving );
			addEventListener( MoveEvent.STARTMOVING, startmoving );
			addEventListener( MoveEvent.ENDMOVING, endmoving );
		}
		private function moving( event:MoveEvent ):void
		{
			_ikMover.moveTo( parent.localToGlobal( event.point ) );
		}
		public function startmoving( event:MoveEvent ):void
		{
			Engine.getInstance().stop();
		}
		public function endmoving( event:MoveEvent ):void
		{
			Engine.getInstance().start();
		}		
	}
}